<?php
namespace app\module\controllers;

class WxController extends BaseController{
    //微信验证token,用于验证消息推送
    public function actionChektoken(){
        $signature = \Yii::$app->request->get("signature");
        $timestamp = \Yii::$app->request->get("timestamp");
        $nonce = \Yii::$app->request->get("nonce");
        $echostr = \Yii::$app->request->get("echostr");

        $token = "lphtwytoken";
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );

        if ($tmpStr == $signature ) {
            return $echostr;
        } else {
            return false;
        }
    }

    public function actionUrl(){
        echo \Yii::$app->request->getHostInfo();
        echo "<br>";
        echo \Yii::$app->request->getBaseUrl();
        $url = \Yii::$app->request->getHostInfo().\Yii::$app->request->getBaseUrl();
        echo $url;
    }
}